Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
process-warning
Advanced tools
A small utility for generating consistent warning objects across your codebase. It also exposes a utility for emitting those warnings, guaranteeing that they are issued only once.
This module is used by the Fastify framework and it was called fastify-warning
prior to version 1.0.0.
npm i process-warning
The module exports a builder function that returns a utility for creating warnings and emitting them.
const warning = require('process-warning')()
warning.create(name, code, message)
name
(string
, required) - The error name, you can access it later with error.name
. For consistency, we recommend prefixing module error names with {YourModule}Warning
code
(string
, required) - The warning code, you can access it later with error.code
. For consistency, we recommend prefixing plugin error codes with {ThreeLetterModuleName}_
, e.g. FST_
. NOTE: codes should be all uppercase.message
(string
, required) - The warning message. You can also use interpolated strings for formatting the message.The utility also contains an emit
function that you can use for emitting the warnings you have previously created by passing their respective code. A warning is guaranteed to be emitted only once.
warning.emit(code [, a [, b [, c]]])
code
(string
, required) - The warning code you intend to emit.[, a [, b [, c]]]
(any
, optional) - Parameters for string interpolation.const warning = require('process-warning')()
warning.create('FastifyWarning', 'FST_ERROR_CODE', 'message')
warning.emit('FST_ERROR_CODE')
How to use an interpolated string:
const warning = require('process-warning')()
warning.create('FastifyWarning', 'FST_ERROR_CODE', 'Hello %s')
warning.emit('FST_ERROR_CODE', 'world')
The module also exports an warning.emitted
Map, which contains all the warnings already emitted. Useful for testing.
const warning = require('process-warning')()
warning.create('FastifyWarning', 'FST_ERROR_CODE', 'Hello %s')
console.log(warning.emitted.get('FST_ERROR_CODE')) // false
warning.emit('FST_ERROR_CODE', 'world')
console.log(warning.emitted.get('FST_ERROR_CODE')) // true
Licensed under MIT.
FAQs
A small utility for creating warnings and emitting them.
The npm package process-warning receives a total of 6,668,058 weekly downloads. As such, process-warning popularity was classified as popular.
We found that process-warning demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.